<template>
  <span v-html="time"></span>
</template>
<script>
  export default {
    data() {
      return {
        time: '',
        flag: false
      }
    },
    mounted() {
      this.timeDown()
      let time = setInterval(() => {
        this.timeDown()
      }, 1000)
    },
    props: {
      createTime:{
        type: String
      },
    },
    methods: {
      timeDown() {
        if (this.createTime) {
          //中文格式转换层世界标准格式
          const endTime = new Date(this.createTime.replace(/-/g, "/")).getTime()
          const nowTime = new Date().getTime();
          let time = Math.ceil((nowTime - endTime) / 1000 / 60)
          if (time >= '60') {
            let h = Math.floor(time / 60)
            let m = time % 60 == 0 ? '' : `${time % 60}分`
            this.time = `调度耗时${h}小时${m}`
          } else {
            this.time = `调度耗时${time}分`
          }
        } else {
          this.time = `未知时间`
        }
      },
    }
  }
</script>
